/* eslint-disable no-control-regex */
import React, { PureComponent } from 'react';
import { Card } from 'antd';
import moment from 'moment';
import StandardTable from '@/components/StandardTable';
import TextOverFlow from '../../components/TextOverFlow';

class EmpInfor extends PureComponent {
  jumpRouting = (targetRouter, id) => {
    const { jumpRouting } = this.props;
    jumpRouting(targetRouter, id);
  };

  getLen = str => {
    if (!str) return null;
    let len = 0;
    for (let i = 0; i < str.length; i += 1) {
      const a = str.charAt(i);
      if (a.match(/[^\x00-\xff]/gi) != null) {
        len += 2;
      } else {
        len += 1;
      }
    }
    return len;
  };

  getCon = str => {
    if (!str) return null;
    let str1 = '';
    let len = 0;
    for (let i = 0; i < str.length; i += 1) {
      const a = str.charAt(i);
      if (a.match(/[^\x00-\xff]/gi) != null) {
        len += 2;
      } else {
        len += 1;
      }
      str1 += a;
      if (len > 18 || len === 18) return str1.concat('...');
    }
    return str1;
  };

  render() {
    const { entryInfo } = this.props;
    const columns = [
      {
        title: '签约方',
        dataIndex: 'sendCorp',
        onHeaderCell: () => ({ style: { fontWeight: 'bolder' } }),
        render: text => <TextOverFlow text={text} />,
      },
      {
        title: '客户名称',
        dataIndex: 'custName',
        onHeaderCell: () => ({ style: { fontWeight: 'bolder' } }),
        render: text => <TextOverFlow text={text} />,
      },
      {
        title: '服务类型',
        dataIndex: 'contType',
        onHeaderCell: () => ({ style: { fontWeight: 'bolder' } }),
      },
      {
        title: '联系状态',
        dataIndex: 'contStateName',
        onHeaderCell: () => ({ style: { fontWeight: 'bolder' } }),
      },
      {
        title: '材料状态',
        dataIndex: 'hdlStateName',
        onHeaderCell: () => ({ style: { fontWeight: 'bolder', textAlign: 'center' } }),
        onCell: () => ({ style: { textAlign: 'center' } }),
      },
      {
        title: '申报状态',
        dataIndex: 'execStateName',
        onHeaderCell: () => ({ style: { fontWeight: 'bolder' } }),
      },
      // {
      //   title: '办理人',
      //   dataIndex: 'tskName',
      //   onHeaderCell: () => ({ style: { fontWeight: 'bolder' } }),
      // },
      {
        title: '所属客服',
        dataIndex: 'creName',
        onHeaderCell: () => ({ style: { fontWeight: 'bolder' } }),
      },
      {
        title: '派单时间',
        dataIndex: 'creTime',
        onHeaderCell: () => ({ style: { fontWeight: 'bolder', textAlign: 'center' } }),
        onCell: () => ({ style: { textAlign: 'center' } }),
        render: val => (val ? moment(val).format('YYYY-MM-DD HH:mm') : '--'),
      },
      {
        title: '操作',
        dataIndex: 'n11',
        onHeaderCell: () => ({ style: { fontWeight: 'bolder', width: 150 } }),
        render: (text, record) => (
          <span
            style={{ color: '#1890FF', cursor: 'pointer' }}
            onClick={() => this.jumpRouting('entryId', record.entryId)}
          >
            查看
          </span>
        ),
      },
    ];
    return (
      <div>
        <Card title={<span>入职办理</span>} id="entryInfor">
          <StandardTable
            selectedRows={[]}
            selectedRowKeys={[]}
            rowSelection={null}
            pagination={false}
            data={entryInfo}
            columns={columns}
            rowKey="entryId"
            onSelectRow={this.handleSelectRows}
            onChange={this.handleStandardTableChange}
          />
        </Card>
      </div>
    );
  }
}

export default EmpInfor;
